using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

namespace DT.Map.Tools
{
    public class MapSetting : MonoBehaviour
    {
        [Header("球场设置")]
        public int FieldWidth = 174;
        public int FieldHeight = 97;
        public int CenterquanRadius = 25;
        public int jingquWidth = 22;
        public int jingquHeight = 49;
        public int qiumen = 9;
        public bool isviewGrid = true;

        MeshRenderer m_mr;
        MeshRenderer mr
        {
            get
            {
                if (m_mr == null)
                {
                    m_mr = GetComponent<MeshRenderer>() as MeshRenderer;
                }
                return m_mr;
            }
        }
        public void Start()
        {
            OnUpdate();
        }
        public void OnValidate()
        {
            OnUpdate();
        }

        void OnUpdate()
        {
            this.transform.localScale = new Vector3(FieldWidth + 2, 1, FieldHeight + 2);
            if (mr != null)
            {
                mr.sharedMaterial.SetFloat("_MapSizeX", FieldWidth);
                mr.sharedMaterial.SetFloat("_MapSizeY", FieldHeight);
                mr.sharedMaterial.SetFloat("_radius", CenterquanRadius);
                mr.sharedMaterial.SetFloat("_jinquw", jingquWidth);
                mr.sharedMaterial.SetFloat("_jinquh", jingquHeight);
                mr.sharedMaterial.SetFloat("_qiumen", qiumen);
                mr.sharedMaterial.SetFloat("_viewGrid", isviewGrid ? 1 : 0);
            }
        }


    }
}

